# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           xcodeversion 1.0
PortGroup           muniversal 1.0

name                tiff
version             4.1.0
revision            0
checksums           rmd160  913703005630320efc075650d5d7776c73c065f9 \
                    sha256  5d29f32517dadb6dbcd1255ea5bbc93a2b54b94fbf83653b4d65c7d6775b8634 \
                    size    2421581

categories          graphics
platforms           darwin
maintainers         {ryandesign @ryandesign} openmaintainer
license             BSD

description         Library and tools for dealing with Tag Image File Format
long_description    \
    This software provides support for the Tag Image File       \
    Format (TIFF), a widely used format for storing image       \
    data.  Included in this software distribution is a          \
    library, libtiff, for reading and writing TIFF, a small     \
    collection of tools for doing simple manipulations of       \
    TIFF images on UNIX systems, documentation on the library   \
    and tools.  A small assortment of TIFF-related software     \
    for UNIX that has been contributed by others is also        \
    included.  The library is capable of dealing with images    \
    that are written to follow the 5.0 or 6.0 TIFF spec.        \
    There is also considerable support for some of the more     \
    esoteric portions of the 6.0 TIFF spec.

homepage            http://simplesystems.org/libtiff/
master_sites        http://download.osgeo.org/libtiff/ \
                    freebsd

depends_lib         port:jpeg \
                    port:xz \
                    port:zlib \
                    port:zstd

test.run            yes
test.target         check

use_autoreconf      yes
autoreconf.args     -fvi

# first patch fixes two problems
#     have typedefs be consistent with OSX headers (see http://trac.macports.org/ticket/41280)
#     prevent configure script from assuming that if we don't want X11, then we don't want OpenGL either
# prevent configure script from finding X11 OpenGL (e.g. mesa & freeglut)
patchfiles          patch-configure.ac.diff \
                    patch-acinclude.m4.diff

configure.args      --disable-jbig \
                    --disable-webp \
                    --with-x=no \
                    --with-docdir=${prefix}/share/doc/${name} \
                    --with-jpeg-include-dir=${prefix}/include \
                    --with-jpeg-lib-dir=${prefix}/lib \
                    --with-lzma-include-dir=${prefix}/include \
                    --with-lzma-lib-dir=${prefix}/lib \
                    --with-zlib-include-dir=${prefix}/include \
                    --with-zlib-lib-dir=${prefix}/lib \
                    --with-zstd-include-dir=${prefix}/include \
                    --with-zstd-lib-dir=${prefix}/lib

use_parallel_build  yes

minimum_xcodeversions {9 3.1}

# tools/tiffgt.c incorrectly uses HAVE_APPLE_OPENGL_FRAMEWORK rather than HAVE_OPENGL_GL_H
# see http://bugzilla.maptools.org/show_bug.cgi?id=2363
configure.cppflags-append \
                    -DHAVE_APPLE_OPENGL_FRAMEWORK

set merger_dont_diff ${prefix}/include/tiffconf.h

variant jbig description {Enable JBIG support} {
    depends_lib-append      port:jbigkit
    configure.args-replace  --disable-jbig --enable-jbig
    configure.args-append   --with-jbig-include-dir=${prefix}/include \
                            --with-jbig-lib-dir=${prefix}/lib
}

livecheck.type  regex
livecheck.url   http://download.osgeo.org/libtiff/
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
